<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="author" content="菜鸟开发小组" />
		<meta name="keywords" content="Hyper IT,hyper it,it,hyper,IT 博客,博客,交流平台,IT交流网站,IT服务网站,菜鸟开发小组"/>
		<meta name="description" content="由菜鸟才发小组开发的一个苛求质量的高大上的IT服务网站，为IT技术圈内的大牛与小白提供了一个良好的技术交流平台。"/>
		<meta name="robots" content="all"/>
		<title>Hyper IT|商品详情</title>
		 
		 <link rel="icon" href="../../img/logo2.ico" type="image/x-icon"/>
		 <link rel="stylesheet" type="text/css" href="../../css/common.css"/>
		 <link rel="stylesheet" type="text/css" href="../../css/detail.css"/>
		 
	</head>
	<body>
		<header>
			<a href="../index.html" title="一个苛求质量的IT服务网站" id="logo"><img src="../../img/logo.jpg" alt="logo"/></a>
			<nav>
				<ul class="link-nav">
					<li><a href="../blog/blogs.html"><i class="m-icon icon-blog"></i><span>博客园</span></a></li>
					<li><a href="../article/articles.html"><i class="m-icon icon-article"></i><span>博文阁</span></a></li>
					<li><a href="../aq/aqs.html"><i class="m-icon icon-aq"></i><span>问答楼</span></a></li>
					<li><a href="../note/notes.html"><i class="m-icon icon-note"></i><span>随笔本</span></a></li>
					<li><a href="../tag/tags.html"><i class="m-icon icon-boll"></i><span>标签库</span></a></li>
				</ul>
			</nav>
					
			<ul class="user-bar">
				<li class="help-search"><a href="../others/help.html">帮助</a></li>
				<li id="userbox"><a href="../user/login.html"><span>Go</span></a></li>
			</ul>
		</header>
		<div class="main">
			<div class="wrap wrap-detail">
				<!--左侧-->
				<div class="market_left">
					<div class="market_left_top">
						<a href="market.html">H币商城</a>
						商品详情
					</div>
					<div class="market_left_bottom">
						<div class="detail_pic">
							<img src=""  width="360" height="360"/>
						</div>
						<div class="detail_info">
							<span style="font-size: 13px;color: #b5b9bc;display: block;">实物名称</span>
							<h2 id="goodsname"></h2>
							<div class="detail_price">
								<span id="price"></span>
								H币
							</div>
							<button class="active" onclick="buyGoods()">立即兑换</button>
							<div class="detail_stock">
								库存<span id="stock"></span>件
							</div>
						</div>
					</div>
				</div>
				<div class="market_right">
					<div class="market_right_top">
							<img src="" width="80" height="80" alt="头像"/>
							<span id="name"></span>
						<a href="../../views/others/help.html" class="coin">
							H币:<span id="hb"></span>
						</a>
					</div>
					<div class="market_right_bottom">
						<a href="order.html"><span class="span_class">兑换记录</span></a>
						<ul id="orderList">
						</ul>
					</div>
				</div>
			</div>
		</div>
		<footer style="clear: both;">
			<div class="wrap">
				<p>Copyright &copy; 2017-5-5 Hyper IT of 菜鸟开发小组 All Rights Reserved.</p>
			</div>
		</footer>
		
		<script type="text/javascript" src="../../js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script type="text/javascript" src="../../js/goods.js"></script>
		<script type="text/javascript">
//			商品详情获取数据
			function aClick(){
				var id = window.location.href.split('?')[1].split('=')[1];
				var url = "/HyperIT/goods/getonegoods";
				var parm = "id="+id;
				$.get(url,parm,function(data){
					if(data.serviceResult){
						var name = data.resultParm.goods.name;
						var cost = data.resultParm.goods.cost;
						var stock = data.resultParm.goods.stock;
						var path = data.resultParm.goods.path;
						$("#goodsname").html(name);
						$("#price").html(cost);
						$("#stock").html(stock);
						$(".detail_pic img").attr('src','../..'+path+'');
					}
					else{
						alert(data.resultInfo);
					}
				});
			}
			aClick();
			function buyGoods(){
				var id = window.location.href.split('?')[1].split('=')[1];
				var user= JSON.parse(getCookie("user"));
				var user_id = user.id;
				var url = "/HyperIT/goods/buyGoods";
				var parm = "id="+id+"&userdetail_id="+user_id;
				$.post(url,parm,function(data){
					if(data.serviceResult){
						messageTip(data.resultInfo);
						aClick();
						$("#hb").html($("#hb").text()-$("#price").text());
					}
					else{
						messageTip(data.resultInfo);
					}
				});
			}
			
		</script>
	</body>
</html>
